package com.tencent.sr.iris.activity.service.config;

import com.google.common.collect.Maps;
import com.tencent.sr.tech.dynamic.config.spring.annotation.DynamicConfigObject;
import java.util.Map;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;
import org.springframework.stereotype.Component;

/**
 * 任务发奖开关 ,false：停止发奖。不配置或者为true：正常发奖
 */
@Getter
@Setter
@Accessors(chain = true)
@ToString
@Component
@DynamicConfigObject(key = "taskIssueSwitchConfig")
public class TaskIssueSwitchConfig {

    private Map<String, Boolean> taskSwitchMap = Maps.newHashMap();

    /**
     * 根据taskId判断是否发奖。false：停止发奖。不配置或者为true：正常发奖
     *
     * @param taskId
     * @return
     */
    public Boolean getTaskSwitch(String taskId) {
        Boolean taskSwitch = taskSwitchMap.get(taskId);
        if (taskSwitch == null) {
            return true;
        }
        return taskSwitch;
    }
}
